gtkpopover: Use event coordinates right away to detect clicks outside.
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 12 May 2017 10:42:48 +0000 (12:42 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 25 May 2017 14:25:59 +0000 (16:25 +0200)
There's no need anymore to translate coordinates, the event already contains
popover-relative ones.

gtk/gtkpopover.c

index 95b363e25e432cb42dc2934ed5f68fb78fe44f49..44a0515625dda31941f8c7afe03b21f153913ae4 100644 (file)
@@ -1410,31 +1410,21 @@ gtk_popover_button_release (GtkWidget      *widget,
                            GdkEventButton *event)
 {
   GtkPopover *popover = GTK_POPOVER (widget);
-  GtkWidget *child, *event_widget;
+  GtkAllocation child_alloc;
+  GtkWidget *child;
 
   child = gtk_bin_get_child (GTK_BIN (widget));
 
   if (!popover->priv->button_pressed)
     return GDK_EVENT_PROPAGATE;
 
-  event_widget = gtk_get_event_widget ((GdkEvent *) event);
-
-  if (child && event->window == gtk_widget_get_window (widget))
-    {
-      GtkAllocation child_alloc;
-
-      gtk_widget_get_allocation (child, &child_alloc);
+  gtk_widget_get_allocation (child, &child_alloc);
 
-      if (event->x < child_alloc.x ||
-          event->x > child_alloc.x + child_alloc.width ||
-          event->y < child_alloc.y ||
-          event->y > child_alloc.y + child_alloc.height)
-        gtk_popover_popdown (popover);
-    }
-  else if (!gtk_widget_is_ancestor (event_widget, widget))
-    {
-      gtk_popover_popdown (popover);
-    }
+  if (event->x < child_alloc.x ||
+      event->x > child_alloc.x + child_alloc.width ||
+      event->y < child_alloc.y ||
+      event->y > child_alloc.y + child_alloc.height)
+    gtk_popover_popdown (popover);
 
   return GDK_EVENT_PROPAGATE;
 }